{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "5dd5ff4f-d917-47b7-bb85-900df0fe0244",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "\n",
    "movies = pd.DataFrame({\n",
    "    'movie_id': [1, 2, 3, 5, 7],\n",
    "    'title': ['t1', 't2', 't3', 't5', 't7'],\n",
    "    'description': ['d1', 'd2', 'd3', 'd5', 'd7']\n",
    "})\n",
    "\n",
    "ratings = pd.DataFrame({\n",
    "    'user_id': [1, 2, 7, 9, 11, 15],\n",
    "    'movie_id': [1, 2, 4, 5, 6, 7],\n",
    "    'title': ['t1', 't2', 't3', 't4', 't5', 't6'],\n",
    "    'rating': [5, 4, 3, 2, 3, 1],\n",
    "    'time': ['t1', 't2', 't4', 't4', 't1', 't3']\n",
    "})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2c5822ef-1b25-4961-9e4b-3f36d99921ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description\n",
       "0         1    t1          d1\n",
       "1         2    t2          d2\n",
       "2         3    t3          d3\n",
       "3         5    t5          d5\n",
       "4         7    t7          d7"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c8e143ab-10da-4829-95b6-a7cecdf840c4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>3</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>15</td>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   user_id  movie_id title  rating time\n",
       "0        1         1    t1       5   t1\n",
       "1        2         2    t2       4   t2\n",
       "2        7         4    t3       3   t4\n",
       "3        9         5    t4       2   t4\n",
       "4       11         6    t5       3   t1\n",
       "5       15         7    t6       1   t3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "ratings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d53d6c19-ca2a-463f-ac8a-428da75192d0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  rating time\n",
       "0         1    t1          d1        1       5   t1\n",
       "1         2    t2          d2        2       4   t2"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "8518ed38-3bbf-47ba-a635-88fc684eb2c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  rating time\n",
       "0         1    t1          d1        1       5   t1\n",
       "1         2    t2          d2        2       4   t2"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on=['movie_id', 'title'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "56515147-84ec-4cbb-ac18-453f75c32e0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title_x description  user_id title_y  rating time\n",
       "0         1      t1          d1        1      t1       5   t1\n",
       "1         2      t2          d2        2      t2       4   t2\n",
       "2         5      t5          d5        9      t4       2   t4\n",
       "3         7      t7          d7       15      t6       1   t3"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on=['movie_id'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9ca318cc-e20a-4416-ad0c-449862f48b60",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id_x</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id_y</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id_x title_x description  user_id  movie_id_y title_y  rating time\n",
       "0           1      t1          d1        1           1      t1       5   t1\n",
       "1           2      t2          d2        2           2      t2       4   t2\n",
       "2           7      t7          d7        7           4      t3       3   t4"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, left_on='movie_id', right_on='user_id') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "821950fd-7799-4b43-ab60-0e9131e5c37f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id_x</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id_y</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>3</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id_x title_x description  user_id  movie_id_y title_y  rating time\n",
       "0           1      t1          d1        1           1      t1       5   t1\n",
       "1           2      t2          d2        2           2      t2       4   t2\n",
       "2           3      t3          d3        7           4      t3       3   t4\n",
       "3           5      t5          d5        9           5      t4       2   t4\n",
       "4           7      t7          d7       11           6      t5       3   t1"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, left_index=True, right_index=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "f2eda73c-53d9-4ed1-b755-bbc32d1367be",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title_left</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title_right</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title_left description  user_id title_right  rating time\n",
       "0         1         t1          d1        1          t1       5   t1\n",
       "1         2         t2          d2        2          t2       4   t2\n",
       "2         5         t5          d5        9          t4       2   t4\n",
       "3         7         t7          d7       15          t6       1   t3"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on=['movie_id'], suffixes=['_left', '_right'])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "275b5fbd-2ba8-422e-a38e-3131eae4b310",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11</td>\n",
       "      <td>3</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  rating time\n",
       "0         1    t1          d1        1       5   t1\n",
       "1         2    t2          d2        2       4   t2\n",
       "2         4    t3         NaN        7       3   t4\n",
       "3         5    t4         NaN        9       2   t4\n",
       "4         6    t5         NaN       11       3   t1\n",
       "5         7    t6         NaN       15       1   t3"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on=['movie_id', 'title'], how='right') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "30f7541c-17ed-46c4-9b07-1470850046df",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "      <th>indicator_col</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>both</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>left_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>right_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>right_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>right_only</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "      <td>right_only</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  rating time indicator_col\n",
       "0         1    t1          d1      1.0     5.0   t1          both\n",
       "1         2    t2          d2      2.0     4.0   t2          both\n",
       "2         3    t3          d3      NaN     NaN  NaN     left_only\n",
       "3         5    t5          d5      NaN     NaN  NaN     left_only\n",
       "4         7    t7          d7      NaN     NaN  NaN     left_only\n",
       "5         4    t3         NaN      7.0     3.0   t4    right_only\n",
       "6         5    t4         NaN      9.0     2.0   t4    right_only\n",
       "7         6    t5         NaN     11.0     3.0   t1    right_only\n",
       "8         7    t6         NaN     15.0     1.0   t3    right_only"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on=['movie_id', 'title'], how='outer', indicator='indicator_col')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "52cadcc4-bef3-490e-bde0-d0003cf9bcdb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id_left</th>\n",
       "      <th>title_left</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id_right</th>\n",
       "      <th>title_right</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>7.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>9.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>15.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>t6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id_left title_left description  user_id  movie_id_right title_right  \\\n",
       "0              1         t1          d1      2.0             2.0          t2   \n",
       "1              2         t2          d2      7.0             4.0          t3   \n",
       "2              3         t3          d3      9.0             5.0          t4   \n",
       "3              5         t5          d5     15.0             7.0          t6   \n",
       "4              7         t7          d7      NaN             NaN         NaN   \n",
       "\n",
       "   rating time  \n",
       "0     4.0   t2  \n",
       "1     3.0   t4  \n",
       "2     2.0   t4  \n",
       "3     1.0   t3  \n",
       "4     NaN  NaN  "
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.join(ratings, on='movie_id', lsuffix='_left', rsuffix='_right') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e5172ed6-daf4-4129-9acb-26b021e8cf31",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id_x</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id_y</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>2.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>7.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t3</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>9.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>15.0</td>\n",
       "      <td>7.0</td>\n",
       "      <td>t6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id_x title_x description  user_id  movie_id_y title_y  rating time\n",
       "0           1      t1          d1      2.0         2.0      t2     4.0   t2\n",
       "1           2      t2          d2      7.0         4.0      t3     3.0   t4\n",
       "2           3      t3          d3      9.0         5.0      t4     2.0   t4\n",
       "3           5      t5          d5     15.0         7.0      t6     1.0   t3\n",
       "4           7      t7          d7      NaN         NaN     NaN     NaN  NaN"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, left_on='movie_id', right_index=True, how='left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "13dae146-03b0-471e-a659-b78ac175a650",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title_left</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title_right</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>movie_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15.0</td>\n",
       "      <td>t6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         title_left description  user_id title_right  rating time\n",
       "movie_id                                                         \n",
       "1                t1          d1      1.0          t1     5.0   t1\n",
       "2                t2          d2      2.0          t2     4.0   t2\n",
       "3                t3          d3      NaN         NaN     NaN  NaN\n",
       "5                t5          d5      9.0          t4     2.0   t4\n",
       "7                t7          d7     15.0          t6     1.0   t3"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.set_index('movie_id').join(ratings.set_index('movie_id'), lsuffix='_left', rsuffix='_right') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f8fdbdb5-dccc-4949-9a80-8f92166117e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15.0</td>\n",
       "      <td>t6</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title_x description  user_id title_y  rating time\n",
       "0         1      t1          d1      1.0      t1     5.0   t1\n",
       "1         2      t2          d2      2.0      t2     4.0   t2\n",
       "2         3      t3          d3      NaN     NaN     NaN  NaN\n",
       "3         5      t5          d5      9.0      t4     2.0   t4\n",
       "4         7      t7          d7     15.0      t6     1.0   t3"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.merge(ratings, on='movie_id', how='left')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "79d93e21-8b92-4ce8-89da-0f71ec5cfd4c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    movie_id title description  user_id  rating time\n",
       "0          1    t1          d1      NaN     NaN  NaN\n",
       "1          2    t2          d2      NaN     NaN  NaN\n",
       "2          3    t3          d3      NaN     NaN  NaN\n",
       "3          5    t5          d5      NaN     NaN  NaN\n",
       "4          7    t7          d7      NaN     NaN  NaN\n",
       "5          1    t1         NaN      1.0     5.0   t1\n",
       "6          2    t2         NaN      2.0     4.0   t2\n",
       "7          4    t3         NaN      7.0     3.0   t4\n",
       "8          5    t4         NaN      9.0     2.0   t4\n",
       "9          6    t5         NaN     11.0     3.0   t1\n",
       "10         7    t6         NaN     15.0     1.0   t3"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings], ignore_index = True) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "e2161059-db24-4d0d-b80d-89f4ec2766cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3.0</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5.0</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7.0</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>3</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15</td>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  movie_id title  rating time\n",
       "0       1.0    t1          d1        1         1    t1       5   t1\n",
       "1       2.0    t2          d2        2         2    t2       4   t2\n",
       "2       3.0    t3          d3        7         4    t3       3   t4\n",
       "3       5.0    t5          d5        9         5    t4       2   t4\n",
       "4       7.0    t7          d7       11         6    t5       3   t1\n",
       "5       NaN   NaN         NaN       15         7    t6       1   t3"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings], axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "a18cc923-158a-468f-ab8b-9377bb6fd71e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>7</td>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>3</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>11</td>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>3</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title description  user_id  movie_id title  rating time\n",
       "0         1    t1          d1        1         1    t1       5   t1\n",
       "1         2    t2          d2        2         2    t2       4   t2\n",
       "2         3    t3          d3        7         4    t3       3   t4\n",
       "3         5    t5          d5        9         5    t4       2   t4\n",
       "4         7    t7          d7       11         6    t5       3   t1"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings], join='inner', axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "f3db3d8a-cbdc-4d09-bdf1-461b4508d51e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>movie_id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         title description  user_id title  rating time\n",
       "movie_id                                              \n",
       "1           t1          d1        1    t1       5   t1\n",
       "2           t2          d2        2    t2       4   t2\n",
       "5           t5          d5        9    t4       2   t4\n",
       "7           t7          d7       15    t6       1   t3"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies.set_index('movie_id'), ratings.set_index('movie_id')], join='inner', axis=1) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "05ac73b9-b398-47d1-8d7a-d4ed6ae7ac40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title_x</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>title_y</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>5</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>4</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>9</td>\n",
       "      <td>t4</td>\n",
       "      <td>2</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>15</td>\n",
       "      <td>t6</td>\n",
       "      <td>1</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title_x description  user_id title_y  rating time\n",
       "0         1      t1          d1        1      t1       5   t1\n",
       "1         2      t2          d2        2      t2       4   t2\n",
       "2         5      t5          d5        9      t4       2   t4\n",
       "3         7      t7          d7       15      t6       1   t3"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(movies, ratings, on='movie_id') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "6be522b3-fe2a-4e66-b04d-ca3bcb163f59",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   movie_id title\n",
       "0         1    t1\n",
       "1         2    t2\n",
       "2         3    t3\n",
       "3         5    t5\n",
       "4         7    t7\n",
       "0         1    t1\n",
       "1         2    t2\n",
       "2         4    t3\n",
       "3         5    t4\n",
       "4         6    t5\n",
       "5         7    t6"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings], axis=0, join='inner') "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "471539d5-22b0-4839-ad73-ee9a832a9eed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    movie_id title description  user_id  rating time\n",
       "0          1    t1          d1      NaN     NaN  NaN\n",
       "1          2    t2          d2      NaN     NaN  NaN\n",
       "2          3    t3          d3      NaN     NaN  NaN\n",
       "3          5    t5          d5      NaN     NaN  NaN\n",
       "4          7    t7          d7      NaN     NaN  NaN\n",
       "5          1    t1         NaN      1.0     5.0   t1\n",
       "6          2    t2         NaN      2.0     4.0   t2\n",
       "7          4    t3         NaN      7.0     3.0   t4\n",
       "8          5    t4         NaN      9.0     2.0   t4\n",
       "9          6    t5         NaN     11.0     3.0   t1\n",
       "10         7    t6         NaN     15.0     1.0   t3"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.append(ratings, ignore_index = True) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "8d4a963f-5ee6-46bf-ab1f-bcfd1d2e01d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    movie_id title description  user_id  rating time\n",
       "0          1    t1          d1      NaN     NaN  NaN\n",
       "1          2    t2          d2      NaN     NaN  NaN\n",
       "2          3    t3          d3      NaN     NaN  NaN\n",
       "3          5    t5          d5      NaN     NaN  NaN\n",
       "4          7    t7          d7      NaN     NaN  NaN\n",
       "5          1    t1         NaN      1.0     5.0   t1\n",
       "6          2    t2         NaN      2.0     4.0   t2\n",
       "7          4    t3         NaN      7.0     3.0   t4\n",
       "8          5    t4         NaN      9.0     2.0   t4\n",
       "9          6    t5         NaN     11.0     3.0   t1\n",
       "10         7    t6         NaN     15.0     1.0   t3"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings], ignore_index = True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "02a3e7c7-f3ca-46bd-92e5-201018c44394",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>movie_id</th>\n",
       "      <th>title</th>\n",
       "      <th>description</th>\n",
       "      <th>user_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1.0</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2.0</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>4</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>5</td>\n",
       "      <td>t4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9.0</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>6</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>11.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>7</td>\n",
       "      <td>t6</td>\n",
       "      <td>NaN</td>\n",
       "      <td>15.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>1</td>\n",
       "      <td>t1</td>\n",
       "      <td>d1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2</td>\n",
       "      <td>t2</td>\n",
       "      <td>d2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>3</td>\n",
       "      <td>t3</td>\n",
       "      <td>d3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>5</td>\n",
       "      <td>t5</td>\n",
       "      <td>d5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>7</td>\n",
       "      <td>t7</td>\n",
       "      <td>d7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    movie_id title description  user_id  rating time\n",
       "0          1    t1          d1      NaN     NaN  NaN\n",
       "1          2    t2          d2      NaN     NaN  NaN\n",
       "2          3    t3          d3      NaN     NaN  NaN\n",
       "3          5    t5          d5      NaN     NaN  NaN\n",
       "4          7    t7          d7      NaN     NaN  NaN\n",
       "5          1    t1         NaN      1.0     5.0   t1\n",
       "6          2    t2         NaN      2.0     4.0   t2\n",
       "7          4    t3         NaN      7.0     3.0   t4\n",
       "8          5    t4         NaN      9.0     2.0   t4\n",
       "9          6    t5         NaN     11.0     3.0   t1\n",
       "10         7    t6         NaN     15.0     1.0   t3\n",
       "11         1    t1          d1      NaN     NaN  NaN\n",
       "12         2    t2          d2      NaN     NaN  NaN\n",
       "13         3    t3          d3      NaN     NaN  NaN\n",
       "14         5    t5          d5      NaN     NaN  NaN\n",
       "15         7    t7          d7      NaN     NaN  NaN"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.concat([movies, ratings, movies], ignore_index = True) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "aecc8774-3e16-47f9-bf46-28faef578029",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>description</th>\n",
       "      <th>movie_id</th>\n",
       "      <th>rating</th>\n",
       "      <th>time</th>\n",
       "      <th>title</th>\n",
       "      <th>user_id</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>d1</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>t1</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>d2</td>\n",
       "      <td>2</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>t2</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>d3</td>\n",
       "      <td>3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>t3</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>d5</td>\n",
       "      <td>5</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>t5</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>d7</td>\n",
       "      <td>7</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>t7</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>1</td>\n",
       "      <td>5.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>t1</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>2</td>\n",
       "      <td>4.0</td>\n",
       "      <td>t2</td>\n",
       "      <td>t2</td>\n",
       "      <td>2.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>4</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>t3</td>\n",
       "      <td>7.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>5</td>\n",
       "      <td>2.0</td>\n",
       "      <td>t4</td>\n",
       "      <td>t4</td>\n",
       "      <td>9.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>6</td>\n",
       "      <td>3.0</td>\n",
       "      <td>t1</td>\n",
       "      <td>t5</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>7</td>\n",
       "      <td>1.0</td>\n",
       "      <td>t3</td>\n",
       "      <td>t6</td>\n",
       "      <td>15.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  description  movie_id  rating time title  user_id\n",
       "0          d1         1     NaN  NaN    t1      NaN\n",
       "1          d2         2     NaN  NaN    t2      NaN\n",
       "2          d3         3     NaN  NaN    t3      NaN\n",
       "3          d5         5     NaN  NaN    t5      NaN\n",
       "4          d7         7     NaN  NaN    t7      NaN\n",
       "0         NaN         1     5.0   t1    t1      1.0\n",
       "1         NaN         2     4.0   t2    t2      2.0\n",
       "2         NaN         4     3.0   t4    t3      7.0\n",
       "3         NaN         5     2.0   t4    t4      9.0\n",
       "4         NaN         6     3.0   t1    t5     11.0\n",
       "5         NaN         7     1.0   t3    t6     15.0"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies.append(ratings, sort = True) \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6781b2b7-796f-4e14-8d64-c251e544cf00",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
